package com.olddriver.crm.web.controller;

import com.olddriver.crm.domain.Menu;
import com.olddriver.crm.service.IMenuService;
import com.olddriver.crm.util.MenuUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("menu")
public class MenuController {
    @Autowired
    private IMenuService menuService;

    @RequestMapping("query")
    @ResponseBody
    public List<Menu> query(Long id) {
        return MenuUtil.handleMenu(menuService.getMenu(id));
    }

    @RequestMapping("subMenu")
    @ResponseBody
    public List<Menu> subMenu(String keyword) {
        System.out.println(keyword);
        return menuService.getSubMenu(keyword);
    }
}
